package com.xbongbong.pro.statistic.enums;

import com.xbongbong.i18n.util.I18nMessageUtil;
import lombok.Getter;

/**
 * 统计表分层层数枚举
 * @author zhouwq
 * @date 2019/5/29 19:19
 */

@Getter
public enum ChartGroupSizeEnum {


    /**
     * 统计表的层级
     */

    GROUP_FIRST(1,"enum.chartGroupSize.describe.group_first"),

    GROUP_SECOND(2,"enum.chartGroupSize.describe.group_second"),

    GROUP_THIRD(3,"enum.chartGroupSize.describe.group_third");


    /**
     * 字段值
     */
    private final Integer code;
    /**
     * 字段描述
     */
    private final String describe;


    ChartGroupSizeEnum(Integer code, String describe){
        this.code = code;
        this.describe = describe;
    }

    /**
     * 根据code获取枚举
     * @param code 层级
     * @return ChartGroupSizeEnum
     */
    public static ChartGroupSizeEnum getByCode(Integer code) {
        for (ChartGroupSizeEnum cacheCode : values()) {
            if (code.equals(cacheCode.getCode())) {
                return cacheCode;
            }
        }
        return null;
    }

    public String getDescribe() {
        return I18nMessageUtil.getMessage(describe);
    }

}
